import { Controller, Get, Post, Body, Param, Delete, Put, Query } from '@nestjs/common';
import { ApiTags } from '@nestjs/swagger';
import { Coupon_Service } from './coupon.service';
import { util_ApiResponse_Base } from '@/common/util/apiResponse';
import { util_Index_ReturnContent } from '@/common/util/index';
import { Coupon_Create_Dto, Coupon_Find_Dto, Coupon_Update_Dto } from './assets/coupon.dto';

@Controller('/adm/coupon')
@ApiTags('coupon 优惠券')
export class Coupon_Controller {
  constructor(private readonly coupon_Service: Coupon_Service) {}

  @Post('/add')
  @util_ApiResponse_Base({
    dataType: 'dataType_add',
  })
  async coupon_Create(@Body() body: Coupon_Create_Dto) {
    return util_Index_ReturnContent(await this.coupon_Service.coupon_Create(body));
  }

  @Get('list')
  @util_ApiResponse_Base({
    dataType: 'dataType_list',
  })
  async coupon_Admin_FindByPage(@Query() query: Coupon_Find_Dto) {
    return util_Index_ReturnContent(await this.coupon_Service.coupon_Admin_FindByPage(query));
  }

  @Put('/update')
  @util_ApiResponse_Base({
    dataType: 'dataType_update',
  })
  async coupon_Update(@Body() body: Coupon_Update_Dto) {
    return util_Index_ReturnContent(await this.coupon_Service.coupon_Update(body));
  }

  @Put('/status/:id')
  @util_ApiResponse_Base({
    dataType: 'dataType_string',
    status: 201,
    description: '发放和停止发放',
    type: '修改成功',
    summary: '发放和停止发放',
  })
  async coupon_ChageStatus(@Param('id') id: string) {
    return util_Index_ReturnContent(await this.coupon_Service.coupon_ChageStatus(id));
  }

  @Put('/stopUse/:id')
  @util_ApiResponse_Base({
    dataType: 'dataType_string',
    status: 201,
    description: '停用和启用优惠券',
    type: '修改成功',
    summary: '停用和启用优惠券',
  })
  async coupon_StopUse(@Param('id') id: string) {
    return util_Index_ReturnContent(await this.coupon_Service.coupon_StopUse(id));
  }

  @Delete('/delete/:id')
  @util_ApiResponse_Base({
    dataType: 'dataType_delete',
  })
  async coupon_Remove(@Param('id') id: string) {
    return util_Index_ReturnContent(await this.coupon_Service.coupon_Remove(+id));
  }
}
